package com.feifei.service.impl;

import com.feifei.bean.Repay;
import com.feifei.bean.RepayExample;
import com.feifei.mapper.RepayMapper;
import com.feifei.service.RepayService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class RepayServiceImpl implements RepayService {
    @Autowired
    RepayMapper repayMapper;

    @Override
    public int addRepay(Repay repay) {
        int i = repayMapper.insert(repay);
        return i;
    }

    @Override
    public Repay getRepayByProductId(Integer productId) {
        RepayExample repayExample=new RepayExample();
        repayExample.createCriteria().andProductIdEqualTo(productId);
        List<Repay> repays = repayMapper.selectByExample(repayExample);
        return repays.get(0);


    }

    @Override
    public int editRepay(Repay repay) {
        int i = repayMapper.updateByPrimaryKeySelective(repay);
        return i;
    }
}
